Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement From<Vec<T>> and FromIterator for FenwickTree #103

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

TonalidadeHidrica
Copy link
Collaborator

We can now construct a new fenwick tree from a vector and an iterator.
What is more, it initializes in an O(n) time (see also this article).

This PR depends on #102, because we cannot implement these traits if we require an additive identity e.

@@ -1,20 +1,22 @@
use std::{iter::FromIterator, ops::AddAssign};

use crate::num_traits::Zero;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These appear to be changes that need not specifically rely on #102. Check out the application examples below.

https://github.com/rust-lang-ja/ac-library-rs/compare/7e99fd2941976764b4e7925898fae7cc77890885...mizar:ac-library-rs:4be604494341a86242b77120e5685740dc41791f?expand=1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous example, we used the Default trait, but now #55 makes it easier to use the Zero trait in user-defined structures as well, the need for the num crate may be lessened.

https://github.com/rust-lang-ja/ac-library-rs/compare/7e99fd2941976764b4e7925898fae7cc77890885...mizar:ac-library-rs:58bcfa92df9a75803b454771f8cb447a580a9cba?expand=1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you rely on internal_type_traits::Zero traits, you will likely need to make this change to check for expand, FYI.
https://github.com/rust-lang-ja/ac-library-rs/compare/7e99fd2941976764b4e7925898fae7cc77890885...mizar:ac-library-rs:fd6bf7f453113c2b1ef5c7dd81c0955de2836cbd?expand=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants